
{***********************************************************}
{                                                           }
{      Informix esql "xa.h"                                 }
{                                                           }
{      Translated to Object Pascal by                       }
{      Copyright (c) 2001-2008 Luxena Software Company      }
{      http://www.luxena.com                                }
{      e-mail: support@luxena.com                           }
{                                                           }
{***********************************************************}

unit IfxXa;

{$I lx.inc}

{$IFDEF VER140_OR_ABOVE}
  {$ALIGN 8}
{$ENDIF}

interface

uses
  IfxTypes;


const
  XIDDATASIZE = 128; // size in bytes
  MAXGTRIDSIZE = 64; // maximum size in bytes of gtrid
  MAXBQUALSIZE = 64; // maximum size in bytes of bqual

  RMNAMESZ = 32; // length of resource manager name, including the null terminator
  MAXINFOSIZE = 256; // maximum size in bytes of xa_info strings, including the null terminator

  // Flag definitions for the RM switch.

  TMNOFLAGS = $00000000; // no RM features selected
  TMREGISTER = $00000001; // RM dynamically registers
  TMNOMIGRATE = $00000002; // RM does not support association migration
  TMUSEASYNC = $00000004; // RM supports async operations


  // Flag definitions for xa_ and ax_ routines
  //
  // use TMNOFLAGS, defined above, when not specifying other flags


  TMASYNC = $80000000; // perform routine asynchronously
  TMONEPHASE = $40000000; // caller is using one-phase commit optimisation
  TMFAIL = $20000000; // dissociates caller and marks transaction branch rollback-only
  TMNOWAIT = $10000000; // return if blocking condition exists
  TMRESUME = $08000000; // caller is resuming association with suspended transaction branch
  TMSUCCESS = $04000000; // dissociate caller from transaction branch
  TMSUSPEND = $02000000; // caller is suspending, not ending, association
  TMSTARTRSCAN = $01000000; // start a recovery scan
  TMENDRSCAN = $00800000; // end a recovery scan
  TMMULTIPLE = $00400000; // wait for any async operation
  TMJOIN = $00200000; // caller is joining existing transaction branch
  TMMIGRATE = $00100000; // caller intends to perform migration


  // ax_() return codes (transaction manager reports to resource manager)

  TM_JOIN = 2; // caller is joining existing transaction branch
  TM_RESUME = 1; // caller is resuming assoc w/suspended transaction branch
  TM_OK = 0; // normal execution
  TMER_TMERR = -1; // an error occurred in trans. manager
  TMER_INVAL = -2; // invalid arguments given
  TMER_PROTO = -3; // routine invoked in improper context


  // xa_() return codes (resource manager reports to transaction manager)

  XA_RBBASE = 100; // The inclusive lower bound of the rollback codes
  XA_RBROLLBACK = XA_RBBASE; // The rollback was caused by an unspecified reason
  XA_RBCOMMFAIL = XA_RBBASE + 1; // The rollback was caused by a communication failure
  XA_RBDEADLOCK = XA_RBBASE + 2; // A deadlock was detected
  XA_RBINTEGRITY = XA_RBBASE + 3; // A condition that violates the integrity of the resources was detected
  XA_RBOTHER = XA_RBBASE + 4; // The RM rolled back the trans. branch for a reason not on this list
  XA_RBPROTO = XA_RBBASE + 5; // A protocol error occurred in the RM
  XA_RBTIMEOUT = XA_RBBASE + 6; // A transaction branch took too long
  XA_RBTRANSIENT = XA_RBBASE + 7; // May retry the transaction branch
  XA_RBEND = XA_RBTRANSIENT; // The inclusive upper bound of the rollback codes

  XA_NOMIGRATE = 9; // resumption must occur where suspension occurred
  XA_HEURHAZ = 8; // the transaction branch may have been heuristically completed
  XA_HEURCOM = 7; // the transaction branch has been heuristically committed
  XA_HEURRB = 6; // the transaction branch has been heuristically aborted
  XA_HEURMIX = 5; // the transaction branch has been heuristically committed and aborted
  XA_RETRY = 4; // routine returned with no effect and may be re-issued
  XA_RDONLY = 3; // the trans was read-only and has been committed
  XA_OK = 0; // normal execution
  XAER_ASYNC = -2; // async. operation already outstanding
  XAER_RMERR = -3; // an RM error occurred in the transaction branch
  XAER_NOTA = -4; // the XID is not valid
  XAER_INVAL = -5; // invalid arguments were given
  XAER_PROTO = -6; // routine invoked in improper context
  XAER_RMFAIL = -7; // RM unavailable
  XAER_DUPID = -8; // the XID already exists
  XAER_OUTSIDE = -9; // RM doing work outside global transaction


type

  // Global transaction identification: XID and NULLXID:

  TXid = record

    formatID: int4; // format identifier
    gtrid_length: int4; // value from 1 through 64
    bqual_length: int4; // value from 1 through 64
    data: array[0..XIDDATASIZE - 1] of Char;
  end;

  XID = TXid;


  // A value of -1 in formatID means that the XID is null.

  // XA Switch Data Structure

  Txa_switch = record
    name: array[0..RMNAMESZ - 1] of Char; // name of resource manager
    flags: int4; // resource manager specific options
    version: int4; // must be 0

    {//* temporary commented

       mint(__cdecl * xa_open_entry)(char * , mint, int4); // xa_open function pointer
       mint(__cdecl * xa_close_entry)(char * , mint, int4); // xa_close function pointer
       mint(__cdecl * xa_start_entry)(XID * , mint, int4); // xa_start function pointer
       mint(__cdecl * xa_end_entry)(XID * , mint, int4); // xa_end function pointer
       mint(__cdecl * xa_rollback_entry)(XID * , mint, int4); // xa_rollback function pointer
       mint(__cdecl * xa_prepare_entry)(XID * , mint, int4); // xa_prepare function pointer
       mint(__cdecl * xa_commit_entry)(XID * , mint, int4); // xa_commit function pointer
       mint(__cdecl * xa_recover_entry)(XID * , int4, mint, int4); // xa_recover function pointer
       mint(__cdecl * xa_forget_entry)(XID * , mint, int4); // xa_forget function pointer
       mint(__cdecl * xa_complete_entry)(mint * , mint * , mint, int4); // xa_complete function pointer

    }
  end;

  //*  extern struct xa_switch_t * fn_xa_switch(void);


  //*  #DEFine infx_xa_switch (*fn_xa_switch())

implementation

end.